package com.faithbj.printer.util;

import cn.com.jautoitx.Keyboard;
import cn.com.jautoitx.Win;

public class KeyUtils {
	/**
	 * 页面设置
	 * @param pageMargin 页边距{left,right,top,down}
	 * @throws InterruptedException
	 */
	public static void pageSettingAndPrint(String ...pageMargin){
	    Keyboard.send("!fu");
	    sleepMe(2000);
		
		Win.activate("页面设置");
		
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		
		Keyboard.send(pageMargin[0]);
		Keyboard.send("{TAB}");
		sleepMe(500);
		
		Keyboard.send(pageMargin[1]);
		Keyboard.send("{TAB}");
		sleepMe(500);
		
		Keyboard.send(pageMargin[2]);
		Keyboard.send("{TAB}");
		sleepMe(500);
		
		Keyboard.send(pageMargin[3]);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{ENTER}");
	}
	/**
	 * 页面设置,调整页面大小
	 * @param pageMargin 页边距{A3,left,right,top,down}
	 * @throws InterruptedException
	 */
	public static void pageScaleAndSetting(String ...pageMargin){
		Keyboard.send("!fu");
		sleepMe(2000);
		
		Win.activate("页面设置");
		sleepMe(500);
		Keyboard.send(pageMargin[0]);
		sleepMe(500);
		
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		
		Keyboard.send(pageMargin[1]);
		Keyboard.send("{TAB}");
		sleepMe(500);
		
		Keyboard.send(pageMargin[2]);
		Keyboard.send("{TAB}");
		sleepMe(500);
		
		Keyboard.send(pageMargin[3]);
		Keyboard.send("{TAB}");
		sleepMe(500);
		
		Keyboard.send(pageMargin[4]);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{TAB}");
		sleepMe(500);
		Keyboard.send("{ENTER}");
	}
	/**
	 * 页面大小设置
	 * @param pageMargin 页边距{left,right,top,down}
	 * @throws InterruptedException
	 */
	public static void pageSettingScale(String direction){
		Keyboard.send("!fu");
		sleepMe(1000);
		Win.activate("页面设置");
		
		Keyboard.send(direction);
		for(int i=0;i<15;i++){
			Keyboard.send("{TAB}");
			sleepMe(500);
		}
		Keyboard.send("{ENTER}");
	}
	
	public static void enterKey(){
		sleepMe(500);
		Win.activate("打印");
		sleepMe(500);
		
		Keyboard.send("{ENTER}");
	}
	
	public static void enter(){
		sleepMe(500);
		Keyboard.send("{ENTER}");
	}
	public static void altTab(){
		sleepMe(500);
		Keyboard.send("!{TAB}");
	}
	public static void closeWin(){
		sleepMe(500);
		Keyboard.send("!fx");
	}
	public static void closeWinAltF(){
		sleepMe(500);
		Keyboard.send("!{F4}");
	}
	public static void pureTab(){
		sleepMe(500);
		Keyboard.send("{TAB}");
	}
	
	
	public static void sleepMe(int milis){
		try {
			Thread.sleep(milis);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	
}
